import {
	request
} from '@/common/oyyl-js/request'
export default {
	computed: {
		userId() {
			return this.$store.getters.userId
		}
	},
	methods: {
		async mpWxLogin(userInfoData) {
			await this.mpWxGetUserInfo(userInfoData)
			this.$util.msg('授权成功');
			setTimeout(() => {
				// uni.navigateBack();
				uni.redirectTo({
					url:'/pages/index/index'
				})
			}, 1000)
		},
		// 获取用户信息
		mpWxGetUserInfo(userInfoData) {
			return new Promise((resolve, reject) => {
				this.$util.throttle(async () => {
					const [loginErr, loginData] = await uni.login({
						provider: 'weixin'
					})
					const [err, userData] = await uni.getUserInfo();
					console.log(loginData,userData,"-----loginData.code");
					resolve(userData)
				})
			}).then(userInfo => {
				this.$store.dispatch('setUserData', userInfo);
				return userInfo
			})
		}	
	
	}
}
